package com.itheima.service.Impl;


import com.itheima.anno.LogOperation;
import com.itheima.Mapper.DeptMapper;
import com.itheima.pojo.Dept;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
   @Autowired
    DeptMapper deptMapper;

    @Override
    @LogOperation

    public List<Dept> list() {
        return deptMapper.list();
    }



    @Override
    public Integer delete(Integer id) {
        return deptMapper.delete(id);
    }

    @Override
    public Integer update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        dept.setCreateTime(LocalDateTime.now());
        return deptMapper.update(dept);
    }



    //添加
    public Integer add(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        return deptMapper.add(dept);
    }
    //根据ID查询
    @Override
    public Dept getById(Integer id) {
        return deptMapper.getById(id);
    }

}
